#include "health.h"
#include<QFont>

Health::Health(QGraphicsItem *parent):QGraphicsTextItem(parent)
{
    reset();
}

void Health::reset()
{
    //字体、位置、颜色
    health=H;
    setPlainText("健康值："+QString::number(health));
    setDefaultTextColor(Qt::black);
    setFont(QFont("Courier New",16,QFont::Bold));
    setPos(x(),16*2);
}

void Health::decrease()
{
    //减少健康值
    --health;
    setPlainText("健康值："+QString::number(health));
}

void Health::increase()
{
    //增加健康值
    ++health;
    setPlainText("健康值："+QString::number(health));
}
